<template>
  <div id="app">
    <div class="eui-list">
      <router-link v-if="!isIndexPage" to="/">回到首页</router-link>
      <div v-else>
        <router-link class="urls" v-for="(item, index) in pageList" :key="index" :to="item">{{ item }}</router-link>
      </div>
    </div>
    <router-view />
  </div>
</template>

<script>
const euiList = require
  .context("./pages/eui/", false, /\.vue$/)
  .keys()
  .map(e => e.replace(/^\.(.*).vue$/, "eui$1"));
const chartList = require
  .context("./pages/chart/", false, /\.vue$/)
  .keys()
  .map(e => e.replace(/^\.(.*).vue$/, "chart$1"));
export default {
  name: "App",
  data() {
    return {
      isIndexPage: true,
      pageList: [...euiList, ...chartList]
    };
  },
  watch: {
    $route() {
      console.log(window.location.hash);
      this.isIndexPage = window.location.hash === "#/";
    }
  }
};
</script>

<style scoped>
.eui-list {
  margin: 20px;
}
.urls {
  display: block;
}
</style>
